# Huawei Technologies Co.,Ltd.

set(RECURSIVE_ARRAY_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/recursive_array.txt)
set(RECURSIVE_ARRAY_BIN ${CMAKE_CURRENT_BINARY_DIR}/recursive_array.abc)
set(RECURSIVE_ARRAY_JS ${CMAKE_CURRENT_SOURCE_DIR}/recursive_array.js)
set(RECURSIVE_ARRAY_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${CMAKE_BINARY_DIR}/pandastdlib/arkstdlib.abc --compiler-enable-jit=false --run-gc-in-place --load-runtimes \"ecmascript\" ${RECURSIVE_ARRAY_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${RECURSIVE_ARRAY_OUTPUT}
    COMMENT "running javascript recursive_array testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${RECURSIVE_ARRAY_JS}  --output ${RECURSIVE_ARRAY_BIN}
    COMMAND rm -f ${RECURSIVE_ARRAY_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} 2>&1 > ${RECURSIVE_ARRAY_OUTPUT}
    COMMAND bash ${RECURSIVE_ARRAY_VERIFY} ${RECURSIVE_ARRAY_OUTPUT}
)
add_custom_target(recursive_array
    DEPENDS ${RECURSIVE_ARRAY_OUTPUT} ${RECURSIVE_ARRAY_VERIFY}
)
add_dependencies(recursive_array es2panda ark)
add_dependencies(ecmascript_common_tests recursive_array)
